cc.Class({
    extends: cc.Component,

    properties: {
        lebelString_num: 0,
    },

    onLoad: function () {
        var label_gonggao = cc.find("content/label_gonggao", this.node);
        // label_gonggao.getComponent(cc.Label).string = "";//设置初始化的公告
        this.runActionByTarget(label_gonggao);
    },
    
    runActionByTarget: function (node) {
        var self = this;
        var zishu = node.getComponent(cc.Label).string.length;
        node.runAction(
            cc.sequence(
            cc.moveTo((5 + zishu * 0.3), cc.p(-(600 + node.getContentSize().width),0)),
            cc.callFunc(this.nextGonggao, this)
            ));
    },
    
    nextGonggao: function () {
        var res = [
            "子弟每是个茅草岗、沙土窝、初生的兔羔儿，乍向围场上走；我是个经笼罩，受索网、苍瓴毛老野鸡，蹅踏得阵马儿熟。经了些窝弓冷箭鑞枪头，不曾落人后，恰不道人到中年万事休，我怎肯虚度了春秋",
            "我是个蒸不烂、煮不熟、槌不匾、炒不爆、响当当一粒铜豌豆；恁子弟每谁教你钻入他锄不断、斫不下、解不开、顿不脱、慢腾腾千层锦套头。我翫的是梁园月，饮的是东京酒，赏的是洛阳花，攀的是章台柳。",
            "我也会围棋、会蹴踘、会打围、会插科、会歌舞、会吹弹、会口燕作、会吟、会双陆。你便是落了我牙，歪了我嘴，瘸了我腿，折了我手，天赐与我这几般儿歹症候，尚兀自不肯休。"
            ]
        var label_gonggao = cc.find("content/label_gonggao", this.node);
        if (this.lebelString_num < res.length) {
            label_gonggao.getComponent(cc.Label).string = res[this.lebelString_num];
            label_gonggao.setPositionX(600);
            this.lebelString_num++;
            this.runActionByTarget(label_gonggao);
        } else {
            this.node.destroy();
        }
    },
});
